package com.wn.class30.service.impl;

import com.wn.class30.entity.ProductImgHead;
import com.wn.class30.entity.ProductImgHeadExample;
import com.wn.class30.mapper.ProductImgHeadDao;
import com.wn.class30.service.ProductImgHeadService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ProductImgHeadServiceImpl implements ProductImgHeadService {
    @Resource
    private ProductImgHeadDao productImgHeadDao;
    @Override
    public List<ProductImgHead> selectProductImgHeadsByProductId(Integer productId) throws Exception {
        ProductImgHeadExample productImgHeadExample = new ProductImgHeadExample();
        ProductImgHeadExample.Criteria criteria = productImgHeadExample.createCriteria();
        criteria.andProductIdEqualTo(productId);
        return productImgHeadDao.selectByExample(productImgHeadExample);

    }

    @Override
    public void insertProductImgHead(ProductImgHead productImgHead) throws Exception {
        productImgHeadDao.insert(productImgHead);
    }

    @Override
    public void deleteProductImgHeadByProductId(Integer productId) throws Exception {
        ProductImgHeadExample productImgHeadExample = new ProductImgHeadExample();
        ProductImgHeadExample.Criteria criteria = productImgHeadExample.createCriteria();
        criteria.andProductIdEqualTo(productId);
        productImgHeadDao.deleteByExample(productImgHeadExample);
    }
}
